package com.example.javapoint.threads.priority;

/**
 * 线程优先级 setPriority() getPriority()
 * 优先级是1-10 默认是5
 * 子线程优先级继承父线程
 */
class ThreadPriorityTest extends Thread {
    @Override
    public void run() {
        System.out.println(Thread.currentThread().getName() +
                " inside thread is running... and the priority is "
                + Thread.currentThread().getPriority());
    }
}

public class ThreadPriority {
    public static void main(String[] args) {
        ThreadPriorityTest t1 = new ThreadPriorityTest();
        ThreadPriorityTest t2 = new ThreadPriorityTest();
        // 设置线程优先级
        t1.setPriority(8);
        t2.setPriority(3);

        t1.start();
        t2.start();
    }
}
